home *** CD-ROM | disk | FTP | other *** search
- Path: hptemp1.cc.umr.edu!phaley
- From: phaley@saucer.cc.umr.edu (Paul Haley)
- Newsgroups: comp.lang.c
- Subject: Need help on program
- Date: 4 Feb 1996 00:41:01 GMT
- Organization: UMR Missouri's Technological University
- Message-ID: <4f0vat$j8j@hptemp1.cc.umr.edu>
- NNTP-Posting-Host: saucer.cc.umr.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Hello. I'm trying to write a program which will count the total
- amount of a "poker" jackpot. I read the input into an array, then read
- the array values in, and take appropriate action.
- c = call
- d = drop
- 5 players are in the game
-
- Example input would be:
- 5cccc
- 5cc10cc
- 100cc5cc
-
- My problem with the program, is that the only time the program is
- 100% correct is when I have a single digit number followed by c's or d's.
- Anything else will give a slightly higher answer than I need. Here is
- the function.
-
- ****** If anybody can help me with this code, I'd be in their debt!
-
- Thanks,
- Paul Haley
-
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
- void array_check(int i, char storage[])
- {
- int pot=0, j=0, temp=0, old_call_value=0, raise=0;
- int call_value=0, num_plays=0, prev=0, c=0, count=0;
- char temp2;
-
- for (j=0; j<i; ++j)
- {
- if (isdigit(storage[j]) != 0)
- {
- if ( prev==1) /* prev means there was a previous digit */
- {
- temp2=storage[j];
- c=atoi(&temp2);
- temp=temp*10+c;
- prev=1;
- }
- else
- {
- temp2=storage[j];
- temp=atoi(&temp2);
- prev=1;
- }
- old_call_value=call_value;
- puts("call_value=temp");
- call_value+=temp;
-
- }
- if (storage[j]=='c') /* begin 'c' check */
- {
- printf("storage[%d] = 'c'\n", j);
- old_call_value=0;
- prev=0;
- } /* end 'c' check */
- if (storage[j]=='d') /* begin 'd' check */
- {
- old_call_value=0;
- prev=0;
- puts("storage[j] = d and prev is set to 0");
- } /* end 'd' check */
- else
- pot+=(call_value-old_call_value);
- }
- end_game(pot);
- }
-
-
-
-